import { Component } from '@angular/core';
import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator';
import { PluginSelector } from './store/plugin/plugin.selector';
import { Store } from '@ngxs/store';
import { MessageSelector } from '@shared/lib/store/message/message.selector';
import { MessageAction } from '@shared/lib/store/message/message.action';

@Component({
  selector: 'app-root',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.scss'],
})
export class AppComponent {

  isCollapsed = false;
  @AutoUnsubscribe() pluginMenu$ = this.store.select(PluginSelector.pluginMenu);

  constructor(
      private store: Store,
  ) {
  }

  ngOnInit() {
    this.store.select(MessageSelector.msg).subscribe(r => {
      if (!r) return;
      // console.log('app-main 收到消息', r);
      //do something
    });
  }

  test1() {
    this.store.dispatch(new MessageAction.Send(111));
  }

  test2() {
    this.store.dispatch(new MessageAction.Send(222));
  }
}
